package cn.doctorpda.conference.ui.common;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;

import cn.doctorpda.conference.R;
import cn.doctorpda.conference.ui.BaseActivity;
import cn.doctorpda.conference.ui.MainActivity;

/**
 * Created by huangjinlong on 2016/5/24.
 */
public class DetailActivity extends BaseActivity {

    private String url;
    private String id;
    private String type;
    private String title;
    private int flag = -1;

    public static void startActivity(Context context, String title, String id, String type, String url) {
        Intent intent = new Intent(context, DetailActivity.class);
        intent.putExtra("id", id);
        intent.putExtra("type", type);
        intent.putExtra("url", url);
        intent.putExtra("title", title);
        context.startActivity(intent);
    }

    public static void startActivityS(Context context, int flag, String title, String id, String type, String url) {
        Intent intent = new Intent(context, DetailActivity.class);
        intent.putExtra("id", id);
        intent.putExtra("type", type);
        intent.putExtra("url", url);
        intent.putExtra("title", title);
        intent.putExtra("flag", flag);
        context.startActivity(intent);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        id = getIntent().getStringExtra("id");
        type = getIntent().getStringExtra("type");
        url = getIntent().getStringExtra("url");
        title = getIntent().getStringExtra("title");
        flag = getIntent().getIntExtra("flag", -1);
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected Fragment createFragment() {
        return DetailFragment.newInstance(title, id, type, url, flag);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_base;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && DetailFragment.mWebView.canGoBack()) {
            DetailFragment.mWebView.goBack();// 返回前一个页面
            return true;
        }
//        T.showShort(this, String.valueOf(DetailFragment.isClick));
        return super.onKeyDown(keyCode, event);
    }
}
